/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.sunspotworld.market;

import org.sunspotworld.sensortasks.routingtasks.AdvertiseTask;
import org.sunspotworld.sensortasks.SensorTask;

/**
 *
 * @author me
 */
public class Bid {
    private SensorTask slot;
    private double value;
    private double dataSize;
    private static final double THRESHOLD = 50;
    
    public Bid(SensorTask task, double bid, double demand) {
        value = bid;
        slot = task;
        dataSize = demand;
    }
    
    public double getValue() {
        return value;
    }
    
    public SensorTask getSlot() {
        return slot;
    }
    
    public void updateValue(double val) {
        if (Math.abs(value - val) > THRESHOLD) {
            value = val;
        } else {
            value = (value*4 + val)/5;
        }
    }
    
    public void updateDemand(double val) {
        if (Math.abs(dataSize - val) > THRESHOLD) {
            dataSize = val;
        } else {
            dataSize = (dataSize*4 + val)/5;
        }
    }
}
